/*
	dlopen API: http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Program-Library-HOWTO.html
	C++ & dlopen API: http://www.isotton.com/devel/docs/C++-dlopen-mini-HOWTO/C++-dlopen-mini-HOWTO.html
*/

#ifndef _BARTER_SERVER_IDATABASE_H_
#define _BARTER_SERVER_IDATABASE_H_

#include "DBQuery.h"
#include <vector>

class IDatabase;

class IDBQueryResult
{
public:
	virtual long GetDoubleWord(std::string) = 0; // 32-bit
	virtual long long GetQuadWord(std::string) = 0; // 64-bit
	virtual std::string GetString(std::string) = 0;
	virtual const char* GetBinaryData(std::string, unsigned long& size) = 0; // size: 32-bit number of the binary data size
	virtual bool NextRow() = 0;
};

struct DatabaseConnectionInfo
{
	std::string Host;
	std::string Pass;
	std::string User;
	std::string DB;
};

/*
	Open: open a connection to the database
	Close: close the connection to the database
	Query: make a database query and return the result
	Exec: make a database query and ignore the result
	BatchExec: perform a set of queries located in a file
*/
class IDatabase
{
public:
	virtual bool Open(DatabaseConnectionInfo*) = 0;
	virtual void Close() = 0;
	virtual IDBQueryResult* Query(DBQuery&) = 0;
	virtual void Exec(DBQuery&) = 0;
	virtual void BatchExec(std::string) = 0;
};

#endif // _BARTER_SERVER_IDATABASE_H_
